<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh-cn">
<head>
  <meta charset="utf-8">
  <title>系统登录</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <link rel="shortcut icon" th:href="@{/favicon.png}" type="image/x-icon">
  <link rel="stylesheet" type="text/css" th:href="@{/res/layui/css/layui.css}">
  <link rel="stylesheet" type="text/css" th:href="@{/res/adminui/dist/css/admin.css}">
  <link rel="stylesheet" type="text/css" th:href="@{/res/adminui/dist/css/login.css}">
  <script type="text/javascript" th:src="@{/res/layui/layui.js}"></script>
  <script type="text/javascript" th:src="@{/res/jquery/jquery.js}"></script>
</head>
<body>
<div class="layadmin-user-login layadmin-user-display-show" style="display: none;">
  <div class="layadmin-user-login-main">
    <div class="layadmin-user-login-box layadmin-user-login-header">
      <h2>用户登录</h2>
    </div>
    <form>
      <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
        <div class="layui-form-item">
          <label class="layadmin-user-login-icon layui-icon layui-icon-username" for="account"></label>
          <input type="text" name="account" id="account" lay-verify="required" placeholder="用户名"
                 autocomplete="auto" class="layui-input" request-text="请输入用户名">
        </div>
        <div class="layui-form-item">
          <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="password"></label>
          <input type="password" name="password" id="password" lay-verify="required" placeholder="密码"
                 autocomplete="current-password" class="layui-input">
        </div>
        <div class="layui-form-item">
          <button class="layui-btn layui-btn-normal layui-btn-fluid" type="button" id="loginBtn">登 录</button>
        </div>
      </div>
    </form>
  </div>
</div>

<script type="text/javascript" th:inline="javascript">
  const contextPath = [[${#httpServletRequest.getContextPath()}]];
</script>
<script type="text/javascript">
  $(function () {
    $("#loginBtn").click(function () {
      const account = $("#account").val();
      const password = $("#password").val();
      $.post(contextPath + "/login", {
        account: account,
        password: password
      }, function (data) {
        if (data.code === 1) {
          window.location.href = contextPath + data.data
        } else {
          layer.msg(data.msg)
        }
      });
    });
  });
</script>
</body>
</html>
